package person.mybatisplusstudy.service;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import person.mybatisplusstudy.po.BaseEntity;

import java.time.LocalDateTime;
import java.util.Date;

/**
 * 具备基础实现的基类.
 *
 * @author 林志鹏
 * @version 1.0.0
 * @date 2021/7/15 0:40
 */
public class BaseService<M extends BaseMapper<T>, T extends BaseEntity> extends ServiceImpl<M, T> implements IBaseService<T>{

    /**
     * 保存自动设置创建时间.
     *
     * @param entity
     * @return
     */
    @Override
    public boolean baseSave(T entity){
        entity.setCreateTime(LocalDateTime.now());
        System.out.println("进来这里设置时间了啦！！！");
        return this.save(entity);
    }
}
